package com.itmk.context;

import lombok.Data;

@Data
public class UserContext {
    private String userId;

    private static final ThreadLocal<UserContextInfo> threadLocal = new ThreadLocal<>();

    public static UserContextInfo getUser() {
        return threadLocal.get();
    }

    /**
     * 设置用户信息
     *
     * @param userContext
     */
    public static void setUser(UserContextInfo userContext) {
        threadLocal.set(userContext);
    }

    /**
     * 移除用户信息
     */
    public static void removeUser() {
        threadLocal.remove();
    }

}
